<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" />
<xsl:template match="/">
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Imports System.Xml
Imports System.Configuration
Imports System.Reflection
Imports ESpace.DALibrary

Namespace <xsl:value-of select="Schema/@NameSpace" />
	Public Class <xsl:value-of select="Schema/@StoreProcedureName" />
		Inherits DataAccessBase
		Public Sub New()
			ConnectionString = ConfigurationSettings.AppSettings("<xsl:value-of select="Schema/@DBName" />")
			MyBase.InitCommand("<xsl:value-of select="concat('[',Schema/@Owner,'].[',Schema/@StoreProcedureName,']')" />")
			ConfigParameter()
		End Sub<xsl:for-each select="Schema/Columns">

		Private param<xsl:value-of select="COLUMN_NAME" /> As SqlParameter
		Public Property <xsl:value-of select="COLUMN_NAME" />() As <xsl:value-of select="LANGUAGE_TYPE" />
			Get
				Return CType(param<xsl:value-of select="COLUMN_NAME" />.Value,<xsl:value-of select="LANGUAGE_TYPE" />)
			End Get
			Set(ByVal Value As <xsl:value-of select="LANGUAGE_TYPE" />)
				param<xsl:value-of select="COLUMN_NAME" />.Value = Value
			End Set
		End Property</xsl:for-each>

		Public Sub ConfigParameter()<xsl:for-each select="Schema/Columns">
			'--------------------------------------------------------
			param<xsl:value-of select="COLUMN_NAME" /> = New SqlParameter()
			param<xsl:value-of select="COLUMN_NAME" />.ParameterName = "@<xsl:value-of select="COLUMN_NAME" />"
			param<xsl:value-of select="COLUMN_NAME" />.SqlDbType = <xsl:value-of select="DB_TYPE" />
			param<xsl:value-of select="COLUMN_NAME" />.Size = <xsl:value-of select="LENGTH" />
			param<xsl:value-of select="COLUMN_NAME" />.Direction = ParameterDirection.<xsl:choose>
				<xsl:when test="COLUMN_TYPE='1'">Input</xsl:when>
				<xsl:when test="COLUMN_TYPE='2'">Output</xsl:when>
				<xsl:when test="COLUMN_TYPE='5'">ReturnValue</xsl:when>
			</xsl:choose>
			param<xsl:value-of select="COLUMN_NAME" />.Value = DBNull.Value
			MyBase.sqlComm.Parameters.Add(param<xsl:value-of select="COLUMN_NAME" />)</xsl:for-each>
		End Sub
	End Class
End Namespace</xsl:template>
</xsl:stylesheet>